package com.budwk.app.sqfwV2.enums;

import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwV2.generator.centuryCitySecurity.excel.*;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 大营路文件对应枚举
 */
@Getter
public enum   CenturyCitySafeServiceEnum {

    // NINE_SMALL_PLACES_SAFETY("nine_small_places_safety_hazard", null, "世纪城街道“九小场所”安全隐患排查登记表", null,"",false), // pdf 世纪城街道“九小场所”安全隐患排查登记表
    /*   CENTER_CITY_GOVER("century_city_nine_small_places_gover", new NineSmallPlacesGoverGenerater(), "", null,null), // excel“九小场所”隐患排查治理台账
     CENTER_CITY_HAZARD("century_city_safety_production_hazard", new SafetyProductionHazardGenerater(), "", null,null), // excel安全生产问题隐患清单
     CENTER_CITY_PROBLEM("century_city_safety_production_problem", new SafetyProductionProblemGenerater(), "", null,null), // excel安全生产问题隐患整改清单
     CENTER_CITY_RISK("century_city_safety_production_risk", new SafetyProductionRiskGenerater(), "", null,null),
 */
    CENTER_CITY_NINE_SMALL_PLACE("century_city_nine_small_places_gover", new NineSmallPlacesNewGenerator(), "", "sqfwV2/centuryCitySecurity/nineSmallPlaces.xlsx", "九小场所", true, "【九小场所安全生产问题隐患清单】", "部分数据|九小场所","/preview/safety/sjc/九小图_excel.png"),
    CENTER_CITY_MULTIPLE_BUSINESS("century_city_safety_production_hazard", new MultipleBusinessHazardsGenerator(), "", "sqfwV2/centuryCitySecurity/multipleBusiness.xlsx", "多业态混合经营场所", true, "【多业态混合经营场所安全生产问题隐患清单】", "部分数据|多业态混合经营场所","/preview/safety/sjc/多业态图_excel.png"), // excel安全生产问题隐患清单
    CENTER_CITY_PERSONNEL_DENSITY("century_city_safety_production_problem", new PersonnelDensityHazardsGenerator(), "", "sqfwV2/centuryCitySecurity/personnelDensity.xlsx", "人员密集场所", true, "【人员密集场所安全生产问题隐患清单】", "部分数据|人员密集场","/preview/safety/sjc/人员密集图_excel.png"), // excel安全生产问题隐患整改清单
    CENTER_CITY_KEY_LOCATION("century_city_safety_production_risk", new KeysLocationsHiddenDangersGenerator(), "", "sqfwV2/centuryCitySecurity/keysLocation.xlsx", "重点场所", true, "【重点场所安全生产问题隐患清单】", "部分数据|重点场所","/preview/safety/sjc/重点场所图_excel.png"),
    CENTER_CITY_BUILDING_HAZARDS("century_city_safety_building_hazards", new BuildingHazardsGenerator(), "", "sqfwV2/centuryCitySecurity/buildingHazards.xlsx", "楼宇", true, "【楼宇安全生产问题隐患清单】", "部分数据|楼宇场所","/preview/safety/sjc/楼宇图_excel.png"),
    CENTER_CITY_BUILDINGS_HIDDEN_DANGERS("century_city_buildings_hidden_dangers", new ResidentialBuildingsHiddenDangersGenerator(), "", "sqfwV2/centuryCitySecurity/residentialBuilding.xlsx", "住宅楼栋", true, "【住宅楼栋安全生产问题隐患清单】", "部分数据|住宅楼栋","/preview/safety/sjc/住宅图_excel.png"),
    CENTER_CITY_SITE_HIDDEN_DANGERS("century_city_site_hidden_dangers", new ConstructionSiteHiddenDangersGenerator(), "", "sqfwV2/centuryCitySecurity/constructionSite.xlsx", "建筑工地", true, "【建筑工地安全生产问题隐患清单】", "部分数据|建筑工地","/preview/safety/sjc/建筑工地图_excel.png"),
    CENTER_CITY_FOOD_SAFE("century_city_food_safe", new FoodSafeGenerator(), "", "sqfwV2/centuryCitySecurity/foodSafeCheck.xlsx", "九小场所", true, "【食品安全排查台账】", "部分数据|餐饮","/preview/safety/sjc/食品安全_excel.png"),
    CENTER_CITY_GAS_SAFE("century_city_gas_safe", new GasGenerator(), "", "sqfwV2/centuryCitySecurity/gas.xlsx", "九小场所", true, "【燃气安全管理监督检查表】", "部分数据|燃气","/preview/safety/sjc/燃气安全_excel.png"),

    ; // excel安全生产问题隐患整改责任清单

    private final String code;

    private final BaseTemplateExcelGenerator service;

    private final String name;

    private final String templatePath;

    private final String type;

    private final boolean loop;

    private final String fileName;

    private final String label;

    private final String previewImage;


    CenturyCitySafeServiceEnum(String code, BaseTemplateExcelGenerator service, String name, String templatePath, String type, boolean loop, String fileName, String label,String previewImage) {
        this.code = code;
        this.service = service;
        this.name = name;
        this.templatePath = templatePath;
        this.type = type;
        this.loop = loop;
        this.fileName = fileName;
        this.label = label;
        this.previewImage=previewImage;
    }

    /**
     * @param code
     * @return
     */
    public static BaseTemplateExcelGenerator getService(String code) {
        Optional<CenturyCitySafeServiceEnum> optional = Arrays.stream(CenturyCitySafeServiceEnum.values()).filter(c -> code.equals(c.getCode())).findFirst();
        return optional.map(CenturyCitySafeServiceEnum::getService).orElse(null);
    }

    /**
     * @param code
     * @return
     */
    public static String getType(String code) {
        for (CenturyCitySafeServiceEnum o : CenturyCitySafeServiceEnum.values()) {
            if (o.getCode().equals(code)) {
                return o.getType();
            }
        }
        return null;
    }

    /**
     * @param code
     * @return
     */
    public static String getLabel(String code) {
        Optional<CenturyCitySafeServiceEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.map(CenturyCitySafeServiceEnum::getLabel).orElse(null);
    }

    /**
     * @param code
     * @return
     */
    public static String getFileName(String code) {
        Optional<CenturyCitySafeServiceEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.map(CenturyCitySafeServiceEnum::getFileName).orElse(null);
    }

    /**
     * @param type
     * @return
     */
    public static String getCodeByType(String type) {
        Optional<CenturyCitySafeServiceEnum> optional = Arrays.stream(values()).filter(e -> e.getType().equals(type)).findFirst();
        return optional.map(CenturyCitySafeServiceEnum::getCode).orElse(null);
    }
}
